﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autofac;
using Autofac.Core;
using Autofac入手.Class;
using Autofac入手.Interface;

namespace Autofac入手
{
    class Program
    {
        public static IContainer Container { get; set; }
        static void Main(string[] args)
        {
            var build = new ContainerBuilder();
            build.RegisterType<OutPut>().As<IOutPut>();
            build.RegisterType<DateWrite>().As<IDateWrite>();
            Container = build.Build();

            WriteDate();

            Console.ReadKey();
        }

        public static void WriteDate()
        {
            using (var scope = Container.BeginLifetimeScope())
            {
                var write = scope.Resolve<IDateWrite>();
                write.WriteDate("当前时间是:" + DateTime.Now.ToShortDateString());
                Console.ReadKey();
            }
        }

    }


}
